﻿angular.module('resources.generateSOAProxy', []);
angular.module('resources.generateSOAProxy').factory('generateSOAProxy', ['rresource', '$http', 'APPSETTING', function (rresource, $http, APPSETTING) {
    var factory = rresource('generateSOA');

    factory.sendEmailUrl = 'api/generateSOA';

    //=========added by alex body中显示附件名+Currency=====================

    //factory.geneateSoaByIds = function (ids,type, successcb, failedcb) {

    //    $http({
    //        url: APPSETTING['serverUrl'] + '/api/generateSOA/generateTemp?Type=' + type,
    //        method: 'POST',
    //        data: ids
    //    }).success(function (response) {
    //        successcb(response);
    //    }).error(function (ex) {
    //        failedcb('error');
    //    });
    //};

    //====================================================================

    factory.getMailInstance = function (customerNums, ids, successcb, failedcb) {

        //=========added by alex body中显示附件名+Currency=====================

        $http({
            url: APPSETTING['serverUrl'] + '/api/generateSOA/generate?customerNums=' + customerNums,
            method: 'POST',
            data: ids
        }).success(function (response) {
            successcb(response);
        }).error(function (ex) {
            failedcb('error');
        });

        //return factory.queryObject({ 'customerNums': customerNums }, successcb, failedcb);
    };

    factory.getMailInstById = function (customerNum, id, ids, successcb, failedcb) {

        //=========added by alex body中显示附件名+Currency=====================

        $http({
            url: APPSETTING['serverUrl'] + '/api/generateSOA/generateTemp?customerNums=' + customerNum + '&templateId=' + id,
            method: 'POST',
            data: ids
        }).success(function (response) {
            successcb(response);
        }).error(function (ex) {
            failedcb('error');
        });

        //return factory.queryObject({ 'customerNums': customerNum, 'templateId': id}, successcb, failedcb);
    }

    factory.geneateSoaByIds = function (ids,type, successcb, failedcb) {

        $http({
            url: APPSETTING['serverUrl'] + '/api/generateSOA/generateAtta?Type=' + type,
            method: 'POST',
            data: ids
        }).success(function (response) {
            successcb(response);
        }).error(function (ex) {
            failedcb('error');
        });
    };

    return factory;
} ]);

